package rollercoaster.railway;

import rollercoaster.commons.Vertex3D;
import rollercoaster.commons.interfaces.ICurve3D;

public class Circle implements ICurve3D{

	public float r;
	public Vertex3D center;
	
	
	public Circle(float r, Vertex3D center) {
		super();
		this.r = r;
		this.center=center;
	}


	public Vertex3D gamma(float t) {
		t=normalize(t);
		return new Vertex3D(center.getX()+r*(float)Math.cos(2*Math.PI*t),center.getY()+ r*(float)Math.sin(2*Math.PI*t), center.getZ());
	}

	public Vertex3D dGammadt(float t) {
		t=normalize(t);
		return new Vertex3D(-2*r*(float)Math.PI*(float)Math.sin(2*Math.PI*t),2*r*(float)Math.PI*(float)Math.cos(2*Math.PI*t) , 0);
	}

	public float getStartPoint() {
		return 0;
	}

	public float getEndPoint() {
		return 1;
	}
	
	public float getR() {
		return r;
	}

	public void setR(float r) {
		this.r = r;
	}

	public float normalize(float t){
		while(t<0){
			t+=1;
		}
		while(t>=1){
			t-=1;
		}
		return t;
	}
	
}
